package com.yang.dao;

import com.yang.entity.NoteOrder;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 订单表(NoteOrder)表数据库访问层
 *
 * @author yangdacheng
 * @since 2022-03-02 19:11:02
 */
@Mapper
@Repository
public interface NoteOrderDao {

//    <result property="orderId" column="orderID" jdbcType="VARCHAR"/>
//        <result property="depositId" column="depositID" jdbcType="VARCHAR"/>
//        <result property="depositTime" column="depositTime" jdbcType="TIMESTAMP"/>
//        <result property="userid" column="userID" jdbcType="VARCHAR"/>

    /**
     * 添加新的订单
     * @param noteOrder
     * @return
     */
    @Insert("INSERT INTO noteOrder " +
            "VALUES(#{orderId},#{depositId},#{depositTime},#{userid})")
    Boolean insertNoteOrder(NoteOrder noteOrder);

    /**
     * 删除订单
     * @param orderID
     * @return
     */
    @Delete("DELETE FROM noteOrder WHERE orderID = #{orderID}")
    Boolean deleteNoteOrder(String orderID);

    /**
     * 根据用户编号获取用户订单
     * @param uid
     * @return
     */
    @Results(value = {
            @Result(column = "orderID",property = "orderId",id = true),
            @Result(column = "depositID",property = "depositId"),
            @Result(column = "depositTime",property = "depositTime"),
            @Result(column = "userid",property = "userID"),
    },id = "orderMapper")
    Boolean queryOrderByUserID(String uid);
}